package networking.messages.syncMessages;

import com.jme.math.Vector3f;

import networking.messages.ProximityMessage;
import networking.messages.SimpleMessage;

public class NodeSyncMessage extends SimpleMessage implements ProximityMessage {
	
	private int intValue, objectID;
	private float floatValue;
	private ValueType type;
	private Vector3f loc;
	
	public NodeSyncMessage() {
		super();
	}
	
	public NodeSyncMessage(int objectID, Object value, ValueType type, Vector3f loc) {
		this();
		this.objectID = objectID;
		this.type = type;
		this.loc = loc;
		
		assert(value != null);
		assert(type != null);
		
		if(value instanceof Integer) intValue = ((Integer)value).intValue();
		else floatValue = ((Float)value).floatValue();
	}
	
	public int getIntValue() { return intValue; }
	
	public float getFloatValue() { return floatValue; }
	
	public int getObjectID() { return objectID; }
	
	public ValueType getType() { return type; }
	
	@Override
	public boolean applies() {
		return !(type == ValueType.HP && getIntValue() == 0);
	}
	
	@Override
	public Vector3f getLocation() {
		return loc;
	}
}